import { createCommonPage, COLUMN_WIDTH } from '@/utils/service.js'
import { dateFormat } from '@/utils/date'

export const createForm = () => ({
  ...createCommonPage(),
})

export const createColumns = (vm) => [
  /* {
    title: '',
    width: 34,
    align: 'center',
    type: 'selection',
  }, */
  {
    title: '序号',
    key: 'id',
    align: 'center',
    width: 80,
    render(h, params) {
      return <div>{(vm.formData.pageNo - 1) * vm.formData.pageSize + params.index + 1}</div>
    },
  },
  {
    title: '稿件标题',
    align: 'center',
    width: COLUMN_WIDTH + 300,
    render(h, params) {
      return <article-title info={params.row}></article-title>
    },
  },
  {
    title: '上传时间',
    align: 'center',
    // sortable: 'custom',
    // sortType: 'desc',
    render(h, params) {
      return <div>{dateFormat(params.row.createTime || '', 'YYYY.MM.DD HH:mm:ss')}</div>
    },
  },
  {
    title: '池内采用量',
    key: 'adoptCount',
    align: 'center',
    sortable: 'custom',
    render(h, params) {
      return (
        <a class="a-normalize" onClick={() => vm.viewAdoptList(params.row)}>
          {params.row.adoptCount || 0}
        </a>
      )
    },
  },
  /* 
  {"id":4,
  "title":"新建视频稿件4",
  "createTime":"2024-08-09 16:55:55",
  "adoptCount":0,"adoptAllCount":0,"clickCount":0,"clickAllCount":0}
  */

  { title: '全平台采用量', key: 'adoptAllCount', align: 'center', sortable: 'custom' },
  { title: '池内点击总量', key: 'clickCount', align: 'center', sortable: 'custom' },
  { title: '全平台点击总量', key: 'clickAllCount', align: 'center', sortable: 'custom' }, // sortType: 'desc'
]
